unit learn_unit1;

{$mode ObjFPC}{$H+}

interface

uses
    Classes, SysUtils;


procedure OutputChinese;

implementation

procedure OutputChinese;
var
    msg: String;      //RawByteString
    conv: String;
begin
    msg := 'Hello, 中国队加油！';
    conv := AnsiToUtf8(msg);
    WriteLn(conv);

    msg := '请输入内容:';
    conv := AnsiToUtf8(msg);
    Write(conv);

    ReadLn(msg);
    conv := AnsiToUtf8('您输入的是：' + msg);

    WriteLn(conv);
    //ReadLn;

end;


initialization
    //windows控制台输入中心需要加入以下2行代码，否则输出为乱码或问号。
    SetMultiByteConversionCodePage(CP_UTF8);
    // SetMultiByteFileSystemCodePage(CP_UTF8); not needed, this is the default under Windows
    SetMultiByteRTLFileSystemCodePage(CP_UTF8);

end.

